package icu.bughub.app.app.viewmodel

import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Description
import androidx.compose.material.icons.filled.SmartDisplay
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel
import icu.bughub.app.app.model.entity.Category
import icu.bughub.app.app.model.entity.DataType
import icu.bughub.app.app.model.entity.SwiperEntity

/**
 * @author huangzehui
 * @date 18/5/2024 下午9:19 周六
 * @description
 */
class MainViewModel : ViewModel() {

    // 分类数据
    val categories by mutableStateOf(
        listOf(
            Category(title = "思想政治"),
            Category(title = "法律法规"),
            Category(title = "职业道德"),
            Category(title = "诚信自律"),
        )
    )

    // 当前分类下标
    var categoryIndex by mutableIntStateOf(0)
        private set

    // 类型数据
    val types by mutableStateOf(
        listOf(
            DataType(
                title = "相关咨讯", icon = Icons.Default.Description
            ),

            DataType(
                title = "视频课程", icon = Icons.Default.SmartDisplay
            )
        )
    )

    // 类型角标
    var typeIndex by mutableIntStateOf(0)
        private set

    // 是否展示文章列表
    val showArticleList: Boolean
        get() {
            return typeIndex == 0
        }

    // 轮播图数据
    val swiperData = listOf(
        SwiperEntity(
            imageUrl = "https://inews.gtimg.com/om_bt/OHyQqgC_5oi4Vm0tlH49XvJzqNBHo2Zryxx5F_be5N2cIAA/1000"
        ),
        SwiperEntity(
            imageUrl = "https://img1.baidu.com/it/u=3689823469,321459310&fm=253&fmt=auto&app=138&f=JPEG?w=750&h=500"
        ),
        SwiperEntity(
            imageUrl = "https://lmg.jj20.com/up/allimg/4k/s/02/210924231A341I-0-lp.jpg"
        ),
        SwiperEntity(
            imageUrl = "https://img0.baidu.com/it/u=2395678313,1439281372&fm=253&fmt=auto&app=138&f=JPEG?w=658&h=439"
        ),
        SwiperEntity(
            imageUrl = "https://img2.baidu.com/it/u=3402688989,1564419070&fm=253&fmt=auto&app=138&f=JPEG?w=1140&h=641"
        )
    )

    val notifications = listOf(
        "领会总书记多次考察港口的深意",
        "东部战区发了一把剑和一首五言绝句",
        "官方通报民工蹲检察院墙边吃饭遭驱赶",
        "一季度三大指标同步增长",
        "国旗军旗与宝岛中央山脉同框",
    )

    /**
     * 更新分类下标
     */
    fun updateCategoryIndex(index: Int) {
        categoryIndex = index
    }

    /**
     * 更新类型角标
     */
    fun updateTypeIndex(index: Int) {
        typeIndex = index
    }
}